using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using System.Collections;
using Ras2ClassLib;

namespace Ras2
{
	public class ListSorter 
		: IComparer
	{
		private ListColumns m_column;
		private SortOrder m_order;

		public ListSorter(ListColumns column, SortOrder order)
		{
			m_column = column;
			m_order = order;
		}

		public int Compare(object a, object b)
		{
			ListViewItem item1 = (ListViewItem)a;
			ListViewItem item2 = (ListViewItem)b;
		
			VinList list1 = (VinList)item1.Tag;
			VinList list2 = (VinList)item2.Tag;
			
			int nRetval = 0;
			switch (m_column)
			{
				case ListColumns.colName:
					nRetval = list1.Name.CompareTo(list2.Name);
					break;
				case ListColumns.colBegin:
					nRetval = list1.Begin.CompareTo(list2.Begin);
					break;
				case ListColumns.colEnd:
					nRetval = list1.End.CompareTo(list2.End);
					break;
			}

			if (m_order == SortOrder.Ascending)
			{
				nRetval = -nRetval;
			}

			return nRetval;
		}
	}

	public class SongSorter
		: IComparer
	{
		private SongColumns m_column;
		private SortOrder m_order;

		public SongSorter(SongColumns column, SortOrder order)
		{
			m_column = column;
			m_order = order;
		}

		public int Compare(object a, object b)
		{
			ListViewItem item1 = (ListViewItem)a;
			ListViewItem item2 = (ListViewItem)b;

			Lag list1 = (Lag)item1.Tag;
			Lag list2 = (Lag)item2.Tag;

			int nRetval = 0;
			switch (m_column)
			{
				case SongColumns.colName:
					nRetval = list1.Name.CompareTo(list2.Name);
					break;
				case SongColumns.colDescription:
					nRetval = list1.Description.CompareTo(list2.Description);
					break;
			}

			if (m_order == SortOrder.Ascending)
			{
				nRetval = -nRetval;
			}

			return nRetval;
		}
	}

	public class PerformerSorter
		: IComparer
	{
		private PerformerColumns m_column;
		private SortOrder m_order;


		public PerformerSorter(PerformerColumns column, SortOrder order)
		{
			m_column = column;
			m_order = order;
		}

		public int Compare(object a, object b)
		{
			ListViewItem item1 = (ListViewItem)a;
			ListViewItem item2 = (ListViewItem)b;

			Flytjandi list1 = (Flytjandi)item1.Tag;
			Flytjandi list2 = (Flytjandi)item2.Tag;


			int nRetval = 0;
			switch (m_column)
			{
				case PerformerColumns.ColName:
					nRetval = list1.Name.CompareTo(list2.Name);
					break;
				case PerformerColumns.ColDescription:
					nRetval = list1.Description.CompareTo(list2.Description);
					break;
			}

			if (m_order == SortOrder.Ascending)
			{
				nRetval = -nRetval;
			}

			return nRetval;
		}
	}
}





